// main.ts
import { createApp } from 'vue'
import ElementPlus from 'element-plus'
import './style.css'
import 'element-plus/dist/index.css'
import 'element-plus/theme-chalk/display.css'
import { createWebHistory, createRouter } from 'vue-router'
import App from './App.vue'

//问卷相关页面
import createQN from './pages/questionnaire/createQN.vue'
import doQN from './pages/questionnaire/doQN.vue'
import qnCenter from './pages/questionnaire/qnCenter.vue'
import reportQN from './pages/questionnaire/reportQN.vue'
import qnListManagement from './pages/questionnaire/qnListManagement.vue'
import anaDistributeTask from './pages/questionnaire/anaDistributeTask.vue'
import qnRecordListManagement from './pages/questionnaire/qnRecordListManagement.vue'
import reviewQNRecord from './pages/questionnaire/reviewQNRecord.vue'

//用户相关页面
import userGroupListManagement from './pages/user/userGroupListManagement.vue'
import userGroupInfo from './pages/user/userGroupInfo.vue'
import login from './pages/user/login.vue'
import register from './pages/user/register.vue'
import userInfo from './pages/user/userInfo.vue'

// 通用页面
import home from './pages/home.vue'
import userCenter from './pages/userCenter.vue'

import distributeTaskQNListManagement from './pages/questionnaire/distributeTaskQNListManagement.vue'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import { createPinia } from 'pinia'
import piniaPersist from 'pinia-plugin-persist'
// import config from '../public/config';
// console.log('MAIN.js:::',config.baseUrl);


const pinia = createPinia()
pinia.use(piniaPersist)

const routes = [
    { path: '/createQN/:id', name: 'createQNWithID', component: createQN },
    { path: '/reviewQNRecord/:id', name: 'reviewQNRecord', component: reviewQNRecord },
    { path: '/createQN', name: 'createQN', component: createQN },
    { path: '/doQN/:id', name: 'doQNWithID', component: doQN },
    { path: '/qnCenter', name: 'qnCenter', component: qnCenter },
    { path: '/reportQN/:id', name: 'reportQN', component: reportQN },
    { path: '/login', name: 'login', component: login },
    { path: '/register', name: 'register', component: register },
    { path: '/userInfo/:id', name: 'userInfo', component: userInfo },
    {
        path: '/userCenter', name: 'userCenter', component: userCenter, redirect: "/userCenter/qnListManagement",
        children: [
            {
                path: 'qnListManagement',
                component: qnListManagement,
                name: "qnListManagement",
                meta: {
                    breadList: [{
                        name: "工作台",
                        path: "/userCenter"
                    }, {
                        name: "问卷管理",
                        path: "/userCenter/qnListManagement"
                    }]
                },
            },
            {
                path: 'distributeTaskQNListManagement',
                component: distributeTaskQNListManagement,
                name: "distributeTaskQNListManagement",
                meta: {
                    breadList: [{
                        name: "工作台",
                        path: "/userCenter"
                    }, {
                        name: "分发任务管理",
                        path: "/userCenter/distributeTaskQNListManagement"
                    }]
                },
            },
            {
                path: 'anaDistributeTask/:id',
                component: anaDistributeTask,
                name: "anaDistributeTask",
                meta: {
                    breadList: [{
                        name: "工作台",
                        path: "/userCenter"
                    }, {
                        name: "分发任务分析",
                        path: "/userCenter/anaDistributeTask/:id"
                    }]
                },
            },


            {
                path: 'userGroupListManagement',
                component: userGroupListManagement,
                name: "userGroupListManagement",
                meta: {
                    breadList: [{
                        name: "工作台",
                        path: "/userCenter"
                    }, {
                        name: "用户组管理",
                        path: "/userCenter/userGroupListManagement"
                    }]
                },
            },
            {
                path: 'userGroupInfo/:id',
                component: userGroupInfo,
                name: "userGroupInfo",
                meta: {
                    breadList: [{
                        name: "工作台",
                        path: "/userCenter"
                    }, {
                        name: "用户组信息",
                        path: "/userCenter/userGroupInfo/:id"
                    }]
                },
            },
            {
                path: 'qnRecordListManagement',
                component: qnRecordListManagement,
                name: "qnRecordListManagement",
                meta: {
                    breadList: [{
                        name: "工作台",
                        path: "/userCenter"
                    }, {
                        name: "测评记录",
                        path: "/userCenter/qnRecordListManagement"
                    }]
                },
            },
            {
                path: 'userInfo/:id',
                component: userInfo,
                name: "userInfo",
                meta: {
                    breadList: [{
                        name: "工作台",
                        path: "/userCenter"
                    }, {
                        name: "个人信息",
                        path: "/userCenter/userInfo/:id"
                    }]
                },
            },
        ]
    },
    { path: '/', name: 'home', component: home },
]

const router = createRouter({
    history: createWebHistory(),
    routes,
})

const app = createApp(App)
app.use(pinia)
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
}
app.use(ElementPlus)
app.use(router)
app.mount('#app')